package chapter04;

public class Test06_exceptionClass {
    public static void main(String[] args) throws DivideMinusException{
        System.out.println(divide(10,5));
        System.out.println(divide(10,-2));
    }
    static int divide(int a,int b) throws DivideMinusException{
        if(b<0){
            throw new DivideMinusException("除数不能是负数");
        }
        return a/b;
    }
}
class DivideMinusException extends Exception{
    public DivideMinusException(){
        super();
    }
    public DivideMinusException(String msg){
        super(msg);
    }
}
